<%@ include file="/common/taglibs.jsp" %>
<script type="text/javascript">
	  $(document).ready(function()
	   {
			  $('.edit-partnergrant-link').click(function() {
					loadDiv('content', 'showEditPartnergrantView.do?id=' + $(this).attr('cipeprojectId'));
				});

			$('.edit-cipeprojectsummary-link').click(function() {
				loadDiv('content', 'showCipeprojectSummary.do?id=' + $(this).attr('cipeprojectId'));
			});	
		 
			 $(".tablesorter").tablesorter().tablesorterPager({container: $("#pager")});	                
      }	
      );
</script>
<%@ include file="/common/pager.jsp" %>
  <security:authorize ifAnyGranted="ROLE_ADMIN,ROLE_GRANTS,ROLE_STAFF,ROLE_KM,ROLE_SENIOR_MANAGEMENT,ROLE_FINANCE">
    <c:set var="canViewPartner" value="true" />
  </security:authorize>
		<table class="tablesorter">
				<c:choose>
					<c:when test="${ !empty cipeprojectList}">
								<thead>
									<c:if test="${messgae!='null'}">
									<tr>
									<th colspan="13"><font size="4"><c:out value="${message}"></c:out></font></th>
									</tr>
									</c:if>									
									<tr>
									  <!--th><spring:message code="common.select.all"/>&#10;<input type="checkbox" id="check-all"></th-->
										<th><spring:message code="cipeprojectlist.table.heading.projectID" /></th>
										<th><spring:message code="cipeprojectlist.table.heading.acronym" /></th>
										<th><spring:message code="cipeprojectlist.table.heading.projectSponsor" /></th>
										<th><spring:message code="cipeprojectlist.table.heading.projectTitle" /></th>
										<th><spring:message code="cipeprojectlist.table.heading.type" /></th>
										<th><spring:message code="cipeprojectlist.table.heading.programOfficer" /></th>
										<th><spring:message code="cipeprojectlist.table.heading.programAssistant" /></th>
										<th><spring:message code="cipeprojectlist.table.heading.region" /></th>
										<th><spring:message code="cipeprojectlist.table.heading.country" /></th>
										<th><spring:message code="cipeprojectlist.table.heading.status" /></th>
										<th><spring:message code="cipeprojectlist.table.heading.startDate" /></th>
										<th><spring:message code="cipeprojectlist.table.heading.endDate" /></th>
										<th><spring:message code="cipeprojectlist.table.heading.managementFunds" /></th>
										<%--<th><spring:message code="cipeprojectlist.table.link.viewProject" /></th> --%>
									</tr>
								</thead>
								<tbody id="paymentRqst">
									<c:forEach items="${cipeprojectList}" var="cipeproject">
									<tr>
										<!--td><input type="checkbox" name="check_element" value="${cipeproject.id}"></td-->
											<td>
                                            <c:choose>
										      <c:when test="${cipeproject.cipeprojecttype.displayName=='Partner'}">
                                                <c:choose>
                                                  <c:when test="${!empty canViewPartner && canViewPartner }">
                                                    <a href="javascript://" class="edit-partnergrant-link" cipeprojectId="${cipeproject.id}">${cipeproject.projectID}</a>
                                                  </c:when>
                                                  <c:otherwise>
                                                    ${cipeproject.projectID}
                                                  </c:otherwise>
                                                </c:choose>
										      </c:when>
											  <c:when test="${cipeproject.cipeprojecttype.displayName!='Partner'}">												
										        <a href="javascript://" class="edit-cipeprojectsummary-link" cipeprojectId="${cipeproject.id}">${cipeproject.projectID}</a>
                                              </c:when>
                                            </c:choose>
											</td>
											<td>${cipeproject.acronym}</td>
											<td>${cipeproject.partner.partnerName}</td>
											<td>${cipeproject.projectTitle}</td>
											<td>${cipeproject.cipeprojecttype.displayName}</td>
											<td>${cipeproject.programOfficer.fullName}</td>
											<td>${cipeproject.programAssistant.fullName}</td>
											<td>${cipeproject.region.displayName}</td>
											<td>${cipeproject.country.displayName}</td>
											<td>${cipeproject.cipeprojectstatus.displayName}</td>
											<td><fmt:formatDate pattern="MM/dd/yyyy" value="${cipeproject.projectStartDate}" /></td>
											<td><fmt:formatDate pattern="MM/dd/yyyy" value="${cipeproject.projectEndDate}" /></td>
											<td><fmt:formatNumber type="currency" value="${cipeproject.managementFunds + cipeproject.partnerGrantFunds}" pattern="$#,##0;"/></td>
											<%--<td><a href="javascript://" class="edit-cipeprojectsummary-link" cipeprojectId="${cipeproject.id}"><spring:message code="label.view" /></a></td>
											<td><a href="javascript://" class="edit-cipeproject-link" cipeprojectId="${cipeproject.id}"><spring:message code="cipeprojectlist.table.link.edit" /></a></td> --%>
										</tr>
									</c:forEach>									 		
										<!--tr align="center"><td colspan="14" align="left"><input type="button" class="blue_btn" name="view" value="View Selected Projects" align="center"></td></tr-->
									</c:when>
								<c:otherwise>
								<c:set  var="m" value="${message}"/>
								<c:if test="${! empty m}">
									<thead>
									<tr>
									<th colspan="12"><font size="4"><c:out value="${message}"></c:out></font></th>
									<tr><td colspan="14"> Your query has returned 0 records </td></tr>
									</thead>
								</c:if>	
								<c:if test="${ !empty param.action}">					  
								   <tr><td colspan="14"> Your query has returned 0 records </td></tr>
								 </c:if>  
								</c:otherwise>
						    </c:choose>		
				
						</tbody>
					</table>	